package com.wsx.ones.boot.test.dubbox;

import com.alibaba.dubbo.config.annotation.Service;
import com.wsx.ones.boot.DubboxApi;
import com.wsx.ones.boot.model.User;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by wangshuaixin on 17/4/8.
 */
@Service(protocol = {"dubbo"})
public class DubboxApiImpl extends AbstractCommonApi implements DubboxApi {

    @Override
    public String hello(String name) {
        return "hello : " + name;
    }

    @Override
    public List<User> getMores(User user, int size) {
        Integer before = before(user);
        switch (before) {
            case 200:
                System.out.print("success");
                break;
            case 500:
                System.out.print("error");
                break;
            default:
                System.out.print("unknow");
                break;
        }
        List<User> users = new ArrayList<User>(size);
        for (int i = 0; i < size; i++) {
            user.setId(i);
            users.add(user);
        }
        Integer after = after(user);
        System.out.print("after:" + after);
        return users;
    }

    @Override
    public Map<String, String> getMap(Map<String, String> map) {
        map.put("rtn", "success");
        return map;
    }
}
